Fox's Git Mirrors
Node / rns-mirrors / Reticulum-Go.git / files / examples / wasm / vendor / github.com / mdlayher / vsock / fd_linux.go
Displaying Raw • Download
examples/wasm/vendor/github.com/mdlayher/vsock/fd_linux.go 633735d797cc5f5d48cb2e22e8fd7cd743930daf (633735d7) Text, 722 B
package vsock
import (
"fmt"
"os"
"golang.org/x/sys/unix"
)
// contextID retrieves the local context ID for this system.
func contextID() (uint32, error) {
f, err := os.Open(devVsock)
if err != nil {
return 0, err
}
defer f.Close()
return unix.IoctlGetUint32(int(f.Fd()), unix.IOCTL_VM_SOCKETS_GET_LOCAL_CID)
}
// isErrno determines if an error a matches UNIX error number.
func isErrno(err error, errno int) bool {
switch errno {
case ebadf:
return err == unix.EBADF
case enotconn:
return err == unix.ENOTCONN
default:
panicf("vsock: isErrno called with unhandled error number parameter: %d", errno)
return false
}
}
func panicf(format string, a ...any) {
panic(fmt.Sprintf(format, a...))
}
Served by rngit 1.5.4 - Generated in 0.02s